package com.hjm.admin.moule.view.activity.impl;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.gigamole.navigationtabstrip.NavigationTabStrip;
import com.hjm.admin.moule.R;
import com.hjm.admin.moule.view.base.BaseActivity;
import com.hjm.admin.moule.view.base.BaseViewPageAdapter;
import com.hjm.admin.moule.view.fragment.impl.BooksInfoFragment;
import com.hjm.admin.moule.viewmodel.BaseViewModel;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class BookListActivity extends BaseActivity {
    @BindView(R.id.viewpager)
    ViewPager mViewPager;
    @BindView(R.id.tabStrip)
    NavigationTabStrip mTabStrip;
    String mTitleName;
    String mGender;
    String titles[] = {"热门", "新书", "好评", "完结"};
    String[] types = {"hot", "new", "reputation", "over"};
    private List<Fragment> mFragments;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setBinddingView(R.layout.activity_book_list, new BaseViewModel(mContext));
    }

    @Override
    protected void initView() {
        mTitleName = getIntent().getStringExtra("titleName");
        mGender = getIntent().getStringExtra("gender");
        initThemeToolBar(mTitleName);
        mFragments = new ArrayList<>();
        for (String type : types) {
            mFragments.add(BooksInfoFragment.newInstance(mTitleName, mGender, type));
        }
        mViewPager.setAdapter(new BaseViewPageAdapter(getSupportFragmentManager(), titles, mFragments));
        mViewPager.setOffscreenPageLimit(4);
        mTabStrip.setTitles(titles);
        mTabStrip.setViewPager(mViewPager);
    }
}
